<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #canvas {
      width: 500px;
      height: 300px;
      background: #0ff;
    }
  </style>
</head>

<body>
  <canvas id="canvas" width="500" height="300"></canvas>
</body>
<script>
  var cvs = document.getElementById("canvas");
  var ctx = cvs.getContext("2d");
  // 每个树状图的高
  var data = [150,200,230,50,200,121,150];
  // 每个树状图的宽
  var w = 50;
  var xside = [];
  var yside = [];
  var allW = 50*data.length;
  var sy = cvs.width - allW;
  var jg = sy/14;
  ctx.fillStyle = "#0000ff";
  for(var i = 0;i<data.length;i++){
    ctx.fillRect(i * 50 + jg*(2*i+1), 300-data[i], 50, data[i]);
  }
  
</script>

</html>